import java.util.ArrayList;
import java.util.List;

public class demo1 {
    List<List<Integer>>list;
    List<Integer>path;
    public List<List<Integer>> subsets(int[] nums) {
        list=new ArrayList<>();
        path=new ArrayList<>();
        dfs(nums,0);
        return list;
    }
    public void dfs(int []nums,int i){
        if(i==nums.length){
            list.add(new ArrayList<>(path));
            return;
        }
        //选中
        path.add(nums[i]);
        dfs(nums,i+1);
        //回溯
        path.remove(path.size()-1);
        //不选
        dfs(nums,i+1);
    }
}
